* Keeping the Team Together: How Intra-Party Divisions Shape Party Behavior Across Issues
* Felix Lehmann
* Department of Political Science, University of Gothenburg
* felix.lehmann@gu.se; Sprängkullsgatan 19, Box 711, 411 23 Göteborg, Sweden

* Replication file for the Appendix (Figure B2 and Table B8)
* Always run the main script first

* change the working directory to the designated folder structure
cd "..."

* add the CCS data to the CMP data
* load dataset 
use "Keeping the team together_data_cmp.dta", replace

// match with CCS
merge m:1 year party_id using "CCS_1_manipulated_cmp.dta", keepusing(multicult_divisions_ccs1 imm_eco_divisions_ccs1 environment_divisions_ccs1 eu_divisions_ccs1 economy_divisions_ccs1 lr_divisions_ccs1 ssm_divisions_ccs1 abortion_divisions_ccs1 order_divisions_ccs1 galtan_divisions_ccs1 ecoint_divisions_ccs1 redist_divisions_ccs1) gen(ccs1)

drop if ccs1 == 2

merge m:1 year party_id using "CCS_2_manipulated_cmp.dta", keepusing(multicult_divisions_ccs2 imm_eco_divisions_ccs2 environment_divisions_ccs2 eu_divisions_ccs2 economy_divisions_ccs2 lr_divisions_ccs2 ssm_divisions_ccs2 abortion_divisions_ccs2 order_divisions_ccs2 galtan_divisions_ccs2 ecoint_divisions_ccs2 redist_divisions_ccs2) gen(ccs2)

drop if ccs2 == 2

merge m:1 year party_id using "CCS_3_manipulated_cmp.dta", keepusing(multicult_divisions_ccs3 imm_eco_divisions_ccs3 environment_divisions_ccs3 eu_divisions_ccs3 economy_divisions_ccs3 lr_divisions_ccs3 ssm_divisions_ccs3 abortion_divisions_ccs3 order_divisions_ccs3 galtan_divisions_ccs3 ecoint_divisions_ccs3 redist_divisions_ccs3) gen(ccs3)

drop if ccs3 == 2

gen multicult_divisions_ccs = .
replace multicult_divisions_ccs = multicult_divisions_ccs1 if multicult_divisions_ccs == .
replace multicult_divisions_ccs = multicult_divisions_ccs2 if multicult_divisions_ccs == .
replace multicult_divisions_ccs = multicult_divisions_ccs3 if multicult_divisions_ccs == .

gen imm_eco_divisions_ccs = .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs1 if imm_eco_divisions_ccs == .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs2 if imm_eco_divisions_ccs == .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs3 if imm_eco_divisions_ccs == .

gen environment_divisions_ccs = .
replace environment_divisions_ccs = environment_divisions_ccs1 if environment_divisions_ccs == .
replace environment_divisions_ccs = environment_divisions_ccs2 if environment_divisions_ccs == .
replace environment_divisions_ccs = environment_divisions_ccs3 if environment_divisions_ccs == .

gen eu_divisions_ccs = .
replace eu_divisions_ccs = eu_divisions_ccs1 if eu_divisions_ccs == .
replace eu_divisions_ccs = eu_divisions_ccs2 if eu_divisions_ccs == .
replace eu_divisions_ccs = eu_divisions_ccs3 if eu_divisions_ccs == .

gen economy_divisions_ccs = .
replace economy_divisions_ccs = economy_divisions_ccs1 if economy_divisions_ccs == .
replace economy_divisions_ccs = economy_divisions_ccs2 if economy_divisions_ccs == .
replace economy_divisions_ccs = economy_divisions_ccs3 if economy_divisions_ccs == .

gen lr_divisions_ccs = .
replace lr_divisions_ccs = lr_divisions_ccs1 if lr_divisions_ccs == .
replace lr_divisions_ccs = lr_divisions_ccs2 if lr_divisions_ccs == .
replace lr_divisions_ccs = lr_divisions_ccs3 if lr_divisions_ccs == .

gen galtan_divisions_ccs = .
replace galtan_divisions_ccs = galtan_divisions_ccs1 if galtan_divisions_ccs == .
replace galtan_divisions_ccs = galtan_divisions_ccs2 if galtan_divisions_ccs == .
replace galtan_divisions_ccs = galtan_divisions_ccs3 if galtan_divisions_ccs == .

gen ssm_divisions_ccs = .
replace ssm_divisions_ccs = ssm_divisions_ccs1 if ssm_divisions_ccs == .
replace ssm_divisions_ccs = ssm_divisions_ccs2 if ssm_divisions_ccs == .
replace ssm_divisions_ccs = ssm_divisions_ccs3 if ssm_divisions_ccs == .

gen abortion_divisions_ccs = .
replace abortion_divisions_ccs = abortion_divisions_ccs1 if abortion_divisions_ccs == .
replace abortion_divisions_ccs = abortion_divisions_ccs2 if abortion_divisions_ccs == .
replace abortion_divisions_ccs = abortion_divisions_ccs3 if abortion_divisions_ccs == .

gen order_divisions_ccs = .
replace order_divisions_ccs = order_divisions_ccs1 if order_divisions_ccs == .
replace order_divisions_ccs = order_divisions_ccs2 if order_divisions_ccs == .
replace order_divisions_ccs = order_divisions_ccs3 if order_divisions_ccs == .

gen ecoint_divisions_ccs = .
replace ecoint_divisions_ccs = ecoint_divisions_ccs1 if ecoint_divisions_ccs == .
replace ecoint_divisions_ccs = ecoint_divisions_ccs2 if ecoint_divisions_ccs == .
replace ecoint_divisions_ccs = ecoint_divisions_ccs3 if ecoint_divisions_ccs == .

gen redist_divisions_ccs = .
replace redist_divisions_ccs = redist_divisions_ccs1 if redist_divisions_ccs == .
replace redist_divisions_ccs = redist_divisions_ccs2 if redist_divisions_ccs == .
replace redist_divisions_ccs = redist_divisions_ccs3 if redist_divisions_ccs == .

label variable eu_divisions_ccs "EU divisions"
label variable imm_eco_divisions_ccs "Immigration (econ) divisions"
label variable multicult_divisions_ccs "Multiculturalism divisions"
label variable economy_divisions_ccs "Economy divisions"
label variable environment_divisions_ccs "Environment divisions"
label variable lr_divisions_ccs "Left-right divisions"
label variable galtan_divisions_ccs "GAL-TAN divisions"
label variable ssm_divisions_ccs "Same-sex marriage divisions"
label variable abortion_divisions_ccs "Abortion divisions"
label variable order_divisions_ccs "Civil liberties divisions"
label variable ecoint_divisions_ccs "Economic intervention divisions"
label variable redist_divisions_ccs "Redistribution divisions"

save "Keeping the team together_data_cmp2.dta", replace

* load dataset 
use "Keeping the team together_data_stacked_cmp.dta", replace

// match with CCS
merge m:1 year party_id using "CCS_1_manipulated_cmp.dta", keepusing(multicult_divisions_ccs1 imm_eco_divisions_ccs1 environment_divisions_ccs1 eu_divisions_ccs1 economy_divisions_ccs1 lr_divisions_ccs1 ssm_divisions_ccs1 abortion_divisions_ccs1 order_divisions_ccs1 galtan_divisions_ccs1 ecoint_divisions_ccs1 redist_divisions_ccs1) gen(ccs1)

drop if ccs1 == 2

merge m:1 year party_id using "CCS_2_manipulated_cmp.dta", keepusing(multicult_divisions_ccs2 imm_eco_divisions_ccs2 environment_divisions_ccs2 eu_divisions_ccs2 economy_divisions_ccs2 lr_divisions_ccs2 ssm_divisions_ccs2 abortion_divisions_ccs2 order_divisions_ccs2 galtan_divisions_ccs2 ecoint_divisions_ccs2 redist_divisions_ccs2) gen(ccs2)

drop if ccs2 == 2

merge m:1 year party_id using "CCS_3_manipulated_cmp.dta", keepusing(multicult_divisions_ccs3 imm_eco_divisions_ccs3 environment_divisions_ccs3 eu_divisions_ccs3 economy_divisions_ccs3 lr_divisions_ccs3 ssm_divisions_ccs3 abortion_divisions_ccs3 order_divisions_ccs3 galtan_divisions_ccs3 ecoint_divisions_ccs3 redist_divisions_ccs3) gen(ccs3)

drop if ccs3 == 2

gen multicult_divisions_ccs = .
replace multicult_divisions_ccs = multicult_divisions_ccs1 if multicult_divisions_ccs == .
replace multicult_divisions_ccs = multicult_divisions_ccs2 if multicult_divisions_ccs == .
replace multicult_divisions_ccs = multicult_divisions_ccs3 if multicult_divisions_ccs == .

gen imm_eco_divisions_ccs = .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs1 if imm_eco_divisions_ccs == .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs2 if imm_eco_divisions_ccs == .
replace imm_eco_divisions_ccs = imm_eco_divisions_ccs3 if imm_eco_divisions_ccs == .

gen environment_divisions_ccs = .
replace environment_divisions_ccs = environment_divisions_ccs1 if environment_divisions_ccs == .
replace environment_divisions_ccs = environment_divisions_ccs2 if environment_divisions_ccs == .
replace environment_divisions_ccs = environment_divisions_ccs3 if environment_divisions_ccs == .

gen eu_divisions_ccs = .
replace eu_divisions_ccs = eu_divisions_ccs1 if eu_divisions_ccs == .
replace eu_divisions_ccs = eu_divisions_ccs2 if eu_divisions_ccs == .
replace eu_divisions_ccs = eu_divisions_ccs3 if eu_divisions_ccs == .

gen economy_divisions_ccs = .
replace economy_divisions_ccs = economy_divisions_ccs1 if economy_divisions_ccs == .
replace economy_divisions_ccs = economy_divisions_ccs2 if economy_divisions_ccs == .
replace economy_divisions_ccs = economy_divisions_ccs3 if economy_divisions_ccs == .

gen lr_divisions_ccs = .
replace lr_divisions_ccs = lr_divisions_ccs1 if lr_divisions_ccs == .
replace lr_divisions_ccs = lr_divisions_ccs2 if lr_divisions_ccs == .
replace lr_divisions_ccs = lr_divisions_ccs3 if lr_divisions_ccs == .

gen galtan_divisions_ccs = .
replace galtan_divisions_ccs = galtan_divisions_ccs1 if galtan_divisions_ccs == .
replace galtan_divisions_ccs = galtan_divisions_ccs2 if galtan_divisions_ccs == .
replace galtan_divisions_ccs = galtan_divisions_ccs3 if galtan_divisions_ccs == .

gen ssm_divisions_ccs = .
replace ssm_divisions_ccs = ssm_divisions_ccs1 if ssm_divisions_ccs == .
replace ssm_divisions_ccs = ssm_divisions_ccs2 if ssm_divisions_ccs == .
replace ssm_divisions_ccs = ssm_divisions_ccs3 if ssm_divisions_ccs == .

gen abortion_divisions_ccs = .
replace abortion_divisions_ccs = abortion_divisions_ccs1 if abortion_divisions_ccs == .
replace abortion_divisions_ccs = abortion_divisions_ccs2 if abortion_divisions_ccs == .
replace abortion_divisions_ccs = abortion_divisions_ccs3 if abortion_divisions_ccs == .

gen order_divisions_ccs = .
replace order_divisions_ccs = order_divisions_ccs1 if order_divisions_ccs == .
replace order_divisions_ccs = order_divisions_ccs2 if order_divisions_ccs == .
replace order_divisions_ccs = order_divisions_ccs3 if order_divisions_ccs == .

gen ecoint_divisions_ccs = .
replace ecoint_divisions_ccs = ecoint_divisions_ccs1 if ecoint_divisions_ccs == .
replace ecoint_divisions_ccs = ecoint_divisions_ccs2 if ecoint_divisions_ccs == .
replace ecoint_divisions_ccs = ecoint_divisions_ccs3 if ecoint_divisions_ccs == .

gen redist_divisions_ccs = .
replace redist_divisions_ccs = redist_divisions_ccs1 if redist_divisions_ccs == .
replace redist_divisions_ccs = redist_divisions_ccs2 if redist_divisions_ccs == .
replace redist_divisions_ccs = redist_divisions_ccs3 if redist_divisions_ccs == .

gen issue_divisions2 = .
// issues
replace issue_divisions2 = eu_divisions_ccs if issue == 2
replace issue_divisions2 = multicult_divisions_ccs if issue == 4
replace issue_divisions2 = environment_divisions_ccs if issue == 6
replace issue_divisions2 = redist_divisions_ccs if issue == 7
replace issue_divisions2 = order_divisions_ccs if issue == 8
replace issue_divisions2 = ssm_divisions_ccs if issue == 9
replace issue_divisions2 = economy_divisions_ccs if issue == 11

label variable issue_divisions2 "Divisions CCS"

save "Keeping the team together_data_stacked_cmp2.dta", replace


use "Keeping the team together_data_cmp2.dta", replace

eststo clear

eststo: reg eu_salience_cmp eu_dissent vote vote_change government i.electiondate
estimate store eu
eststo: reg multi_salience_cmp multicult_dissent vote vote_change government i.electiondate
estimate store mc
eststo: reg lrecon_salience_cmp lrecon_dissent vote vote_change government i.electiondate
estimate store ec

set scheme s1mono
coefplot eu mc ec ||, xline(0) keep(eu_dissent multicult_dissent lrecon_dissent) byopts(cols(3) xrescale legend(off)) title("(A) CHES divisions indicator", size(medium)) levels(90) mlabel(cond(@pval<.001, string(@b, "%9.2fc") + "***", ///
cond(@pval<.01, string(@b, "%9.2fc") + "**" , ///
cond(@pval<.05, string(@b, "%9.2fc") + "*"  , ///
cond(@pval<.1, string(@b, "%9.2fc") + "+", ///
string(@b, "%9.2fc")))))) ///
mlabposition(12) grid(none) msymbol(s) color(blue) ciopts(lcolor(dknavy) legend(off)) caption("90% CIs; + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001", position(5) justification(right) size(vsmall)) 

graph export "figb2a.png", replace

// visualize regression results - CCS
use "Keeping the team together_data_cmp2.dta", replace
eststo clear

eststo: reg eu_salience_cmp eu_divisions_ccs vote vote_change government i.electiondate
estimate store eu
eststo: reg multi_salience_cmp multicult_divisions_ccs vote vote_change government i.electiondate
estimate store mc
eststo: reg enviro_salience_cmp environment_divisions_ccs vote vote_change government i.electiondate
estimate store ev
eststo: reg lrecon_salience_cmp economy_divisions_ccs vote vote_change government i.electiondate
estimate store ec
*eststo: qui: reg redist_salience_cmp redist_divisions_ccs vote vote_change government i.electiondate
*estimate store rd
eststo: reg civlib_salience_cmp order_divisions_ccs vote vote_change government i.electiondate
estimate store cl
eststo: reg social_salience_cmp ssm_divisions_ccs vote vote_change government i.electiondate
estimate store sl

set scheme s1mono
coefplot eu mc ev ec cl sl ||, xline(0) keep(eu_divisions_ccs multicult_divisions_ccs environment_divisions_ccs order_divisions_ccs ssm_divisions_ccs economy_divisions_ccs) byopts(cols(4) xrescale legend(off)) title("(B) CCS divisions indicator", size(medium)) levels(90) mlabel(cond(@pval<.001, string(@b, "%9.2fc") + "***", ///
cond(@pval<.01, string(@b, "%9.2fc") + "**" , ///
cond(@pval<.05, string(@b, "%9.2fc") + "*"  , ///
cond(@pval<.1, string(@b, "%9.2fc") + "+", ///
string(@b, "%9.2fc")))))) ///
mlabposition(12) grid(none) msymbol(s) color(blue) ciopts(lcolor(dknavy) legend(off)) caption("90% CIs; + p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001", position(5) justification(right) size(vsmall)) 

graph export "figb2b.png", replace

use "Keeping the team together_data_stacked_cmp2.dta", replace

eststo clear
// H1
eststo: qui: reghdfe salience issue_divisions1 vote vote_change government, cluster(cmp_id) absorb(issue electiondate)
estadd local election "Yes"
estadd local issue "Yes"
estadd local cluster "Yes"
eststo: qui: reghdfe salience issue_divisions2 vote vote_change government, cluster(cmp_id) absorb(issue electiondate)
estadd local election "Yes"
estadd local issue "Yes"
estadd local cluster "Yes"

esttab using b8.rtf, replace label varwidth(16) se modelwidth(5) compress nogap onecell stats(N election issue cluster, fmt(a2) label ("Observations" "Election FEs" "Issue FEs" "Clustered SEs")) star (+ 0.1 * 0.05 ** 0.01 *** 0.001) nonumbers mtitles(H1 H1) note("Notes: Pooled multivariate regression models testing the effect of issue-specific intra-party divisions on issue salience (H1) using manifesto-based salience measures. Model 1 uses the CHES divisions indicator and model 2 uses the CCS divisions indicator. Clustered standard errors in parentheses.") b(%9.3fc) order(issue_divisions1 issue_divisions2 vote vote_change government _cons) keep(issue_divisions1 issue_divisions2 vote vote_change government _cons)

